package component.auxiliares.view;

import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;

import component.auxiliares.Texto;


/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
@SuppressWarnings("serial")
public class labelConfig extends javax.swing.JFrame {
	private JLabel lblTexto;
	private JTextField txtTexto;
	private JButton btnCancelar;
	private JButton btnOk;
	private JSeparator jSeparator1;
	private JPanel btnCor;
	private JLabel lblCor;
	private JComboBox cmbTamanho;
	private JLabel lblTamanho;
	private JComboBox cmbFontes;
	private JLabel lblFonte;
	private Texto main;

	private Color color = new Color(0, 0, 0);

	/**
	 * Auto-generated main method to display this JFrame
	 */
	// public static void main(String[] args) {
	// SwingUtilities.invokeLater(new Runnable() {
	// public void run() {
	// labelConfig inst = new labelConfig(new Texto());
	// inst.setLocationRelativeTo(null);
	// inst.setVisible(true);
	// }
	// });
	// }
	public labelConfig(Texto j) {
		super();
		main = j;
		initGUI();
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("i2M - Texto");
			{
				lblTexto = new JLabel();
				getContentPane().add(lblTexto);
				lblTexto.setText("Texto:");
				lblTexto.setBounds(12, 12, 44, 14);
			}
			{
				txtTexto = new JTextField();
				getContentPane().add(txtTexto);
				txtTexto.setBounds(56, 9, 222, 21);
			}
			{
				lblFonte = new JLabel();
				getContentPane().add(lblFonte);
				lblFonte.setText("Fonte:");
				lblFonte.setBounds(12, 38, 44, 14);
			}
			{
				ComboBoxModel cmbFontesModel = new DefaultComboBoxModel(
						new String[] { "Arial", "Serif", "TimesRoman" });
				cmbFontes = new JComboBox();
				getContentPane().add(cmbFontes);
				cmbFontes.setModel(cmbFontesModel);
				cmbFontes.setBounds(56, 35, 222, 21);
			}
			{
				lblTamanho = new JLabel();
				getContentPane().add(lblTamanho);
				lblTamanho.setText("Tamanho:");
				lblTamanho.setBounds(12, 64, 60, 14);
			}
			{
				ComboBoxModel cmbTamanhoModel = new DefaultComboBoxModel(
						new String[] { "10", "12", "14", "16", "18", "24",
								"28", "32" });
				cmbTamanho = new JComboBox();
				getContentPane().add(cmbTamanho);
				cmbTamanho.setModel(cmbTamanhoModel);
				cmbTamanho.setBounds(84, 61, 66, 21);
			}
			{
				lblCor = new JLabel();
				getContentPane().add(lblCor);
				lblCor.setText("Cor:");
				lblCor.setBounds(204, 64, 32, 14);
			}
			{
				btnCor = new JPanel();
				getContentPane().add(btnCor);
				btnCor.setBackground(new Color(0, 0, 0));
				btnCor.setBounds(242, 61, 36, 17);
				btnCor.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1,
						false));
				btnCor.setPreferredSize(new java.awt.Dimension(10, 21));
				btnCor.setSize(36, 21);
				btnCor.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						btnCorMouseClicked(evt);
					}
				});
			}
			{
				jSeparator1 = new JSeparator();
				getContentPane().add(jSeparator1);
				jSeparator1.setBounds(12, 88, 266, 10);
			}
			{
				btnOk = new JButton();
				getContentPane().add(btnOk);
				btnOk.setText("OK");
				btnOk.setBounds(12, 97, 103, 21);
				btnOk.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						btnOkMouseClicked(evt);
					}
				});
			}
			{
				btnCancelar = new JButton();
				getContentPane().add(btnCancelar);
				btnCancelar.setText("Cancelar");
				btnCancelar.setBounds(174, 97, 104, 21);
				btnCancelar.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						btnCancelarMouseClicked(evt);
					}
				});
			}
			pack();
			this.setSize(298, 161);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public JComboBox getCmbFontes() {
		return cmbFontes;
	}

	public JComboBox getCmbTamanho() {
		return cmbTamanho;
	}

	public JPanel getBtnCor() {
		return btnCor;
	}

	public Color getColor() {
		return color;
	}

	public JTextField getText() {
		return txtTexto;
	}

	private void btnCancelarMouseClicked(MouseEvent evt) {
		this.dispose();
	}

	private void btnCorMouseClicked(MouseEvent evt) {
		color = JColorChooser.showDialog(null, "Escolha uma cor", new Color(0,
				0, 0));
		btnCor.setBackground(color);
		btnOk.requestFocus();
	}

	private void btnOkMouseClicked(MouseEvent evt) {
		main.atualiza(this);
	}
}
